﻿using System;
using SlimDX.DirectInput;

namespace TileGert
{
  /// <summary>
  /// GertInput gives you access to input devices using DirectInput.
  /// </summary>
  public class GertInput
  {
    private GertKeyboardInput _keyboard = null;
    private GertMouseInput _mouse = null;
    private GertJoystickInput _joystick = null;
    private GertGame _game = null;
    
    /// <summary>
    /// Creates a new GertInputa dn Initialzes DriectInput.
    /// </summary>
    public GertInput(GertGame game)
    {
      _game = game;
      DirectInput.Initialize();
    }
    
    /// <summary>
    /// Gets the keyboard input controller.
    /// </summary>
    public GertKeyboardInput Keyboard
    {
      get
      {
        if (_keyboard == null)
          _keyboard = new GertKeyboardInput(_game);
        return _keyboard;
      }
    }
    
    /// <summary>
    /// Gets the mouse input controller.
    /// </summary>
    public GertMouseInput Mouse
    {
      get
      {
        if (_mouse == null)
          _mouse = new GertMouseInput(_game);
        return _mouse;
      }
    }
    
    /// <summary>
    /// Gets the joystick input controller.
    /// </summary>
    public GertJoystickInput Joystick
    {
      get
      {
        if (_joystick == null)
          _joystick = new GertJoystickInput(_game);
        return _joystick;
      }
    }
    
    /// <summary>
    /// Updates the current state of the keyboard, mouse and joysticks.
    /// </summary>
    public void Update()
    {
      Keyboard.Update();
      Mouse.Update();
      Joystick.Update();
    }
    
  }
}
